#include "common.h"
#include "sdlwindow.h"
#include "game.h"

int process_events()
{
	SDL_Event event;
	while(SDL_PollEvent(&event))
	{
		switch(event.type) 
    	{
    		// exit on escape
    		case SDL_KEYDOWN:
    			if(event.key.keysym.sym == SDLK_ESCAPE)
    			{
     				SDL_Quit();
     				return 0;
     			}
     			if(SDLK_SPACE == event.key.keysym.sym) {
     			    tank_shoot();
     			}
     			if(SDLK_UP == event.key.keysym.sym) {
     			    tank_move();
     			}
     			if(SDLK_LEFT == event.key.keysym.sym) {
     			    tank_rotate_left();
     			}
     			if(SDLK_RIGHT == event.key.keysym.sym) {
     			    tank_rotate_right();
     			}
     			break;
     		// exit on window close button
     		case SDL_QUIT:
     			return 0;
    	}
    	
 	}
 	return 1;
}



int main()
{
    sdl_create_window();
	game_init();
	while(process_events()) 
	{
    	game_main();
    }
	return 0;
}
